<template>
  <div class="dashboard-editor-container">

    <!-- <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <raddar-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <bar-chart />
        </div>
      </el-col>
    </el-row> -->
    <el-row :gutter="20">
       <el-col :span="16">
         <el-row class="topNumItems" type="flex"  justify="space-between">
           <el-col class="col-num" :span='8' v-for="i in 3" :key='i'>
              <TopNum />
            </el-col>
         </el-row>
         <el-row class="base-content">
            <div class="sjgk-content">
               <div class="sjgk-top global-flex-bc">
                 <topTitle name='气象数据概况' time='2022-04-17 12:34:56' />
                 <div class="tip-selects global-flex-ec">
                     <tipInfo>光照强度超过50Lux，风速超过4m/s，降雨量超过20mm</tipInfo>
                     <div class="selects">
                       <el-select size='mini' v-model="value" placeholder="请选择">
                          <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                     </div>
                 </div>
               </div>  
               <div class="nav-items global-flex-bc">
                 <div class="nav-item  global-flex-bc" v-for="i in 6" :key='i'>
                    <div class="global-left">
                       <div class="name">空气湿度</div> 
                       <div class="value">23%</div>
                    </div>
                    <img class="global-right imgIcon" src="" alt="">
                 </div>
               </div>
               <div class="echart-content">
                 <div class="echart-opt global-flex-ec">
                    <div class="selectBox global-flex-bc">
                       <div class="box ">日</div>
                       <div class="box ">月</div>
                       <div class="box active">年</div>
                    </div>
                    <div class="selectBox global-flex-bc">
                       <div class="box">前七天</div>
                       <div class="box">前30天</div>
                       <div class="box">前60天</div>
                    </div>
                 </div>
                  <div class="echarts"></div>
               </div>
            </div>
         </el-row>
         <el-row class="base-content">
            <div class="sjgk-content">
               <div class="sjgk-top global-flex-bc">
                 <topTitle name='墒请数据概况' time='2022-04-17 12:34:56' />
                 <div class="tip-selects global-flex-ec">
                     <tipInfo>土壤湿度超过20%</tipInfo>
                     <div class="selects">
                       <el-select size='mini' v-model="value" placeholder="请选择">
                          <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                     </div>
                 </div>
               </div>  
               <div class="nav-items global-flex-bc">
                 <div class="nav-item  global-flex-bc" v-for="i in 6" :key='i'>
                    <div class="global-left">
                       <div class="name">空气湿度</div> 
                       <div class="value">23%</div>
                    </div>
                    <img class="global-right imgIcon" src="" alt="">
                 </div>
               </div>
               <div class="echart-content">
                 <div class="echart-opt global-flex-ec">
                    <div class="selectBox global-flex-bc">
                       <div class="box ">日</div>
                       <div class="box ">月</div>
                       <div class="box active">年</div>
                    </div>
                    <div class="selectBox global-flex-bc">
                       <div class="box">前七天</div>
                       <div class="box">前30天</div>
                       <div class="box">前60天</div>
                    </div>
                 </div>
                  <div class="echarts"></div>
               </div>
            </div>
         </el-row>
       </el-col>
       <el-col :span="8">
         <el-row class="base-content left-base">
           <div class="sjgk-top global-flex-bc">
                 <topTitle style="flex:2" name='最新虫情' time='2022-04-17' />
                 <div class="tip-selects global-flex-ec" style="flex:1">
                     <div class="selects">
                       <el-select size='mini' v-model="value" placeholder="请选择">
                          <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                     </div>
                 </div>
           </div> 
           <tipInfo style="width:">始见金龟子超过10头，瓢虫超过23头</tipInfo>
         </el-row>
         <el-row class="base-content left-base">
           <div class="sjgk-top global-flex-bc">
                 <topTitle  class="left-title" name='最新苗情长势' time='2022-04-17' />
           </div> 
           <div class="tip-selects global-flex-ec">
                     <div class="selects global-flex-bc">
                       <el-select size='mini' style="width:46%" v-model="value" placeholder="请选择">
                          <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                        <el-select size='mini' style="width:46%" v-model="value" placeholder="请选择">
                          <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                     </div>
            </div>
         </el-row>
         <el-row class="base-content left-base">
           <div class="sjgk-top global-flex-bc">
                 <topTitle  style="flex:2"  class="left-title" name='最新孢子概况' time='2022-04-17' />
                 <div class="tip-selects global-flex-ec"  style="flex:1" >
                     <div class="selects">
                       <el-select size='mini' v-model="value" placeholder="请选择">
                          <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                     </div>
                 </div>
           </div> 
         </el-row>
        </el-col>
    </el-row>
    
  </div>
</template>

<script>
// import PanelGroup from './dashboard/PanelGroup'
// import LineChart from './dashboard/LineChart'
// import RaddarChart from './dashboard/RaddarChart'
// import PieChart from './dashboard/PieChart'
// import BarChart from './dashboard/BarChart'
import TopNum from './dashboard/TopNum'
import tipInfo from '@/components/dashboard/tipInfo'
import topTitle from '@/components/dashboard/topTitle'
import {testDP, obtainDeviceData} from "@/api/login";

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}

export default {
  name: 'Index',
  components: {
    // PanelGroup,
    // LineChart,
    // RaddarChart,
    // PieChart,
    // BarChart,
    tipInfo,
    topTitle,
    TopNum
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      options: [{
          value: '选项1',
          label: '黄金糕'
        }, {
          value: '选项2',
          label: '双皮奶'
        }, {
          value: '选项3',
          label: '蚵仔煎'
        }, {
          value: '选项4',
          label: '龙须面'
        }, {
          value: '选项5',
          label: '北京烤鸭'
        }],
        value: ''
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  },
  created(){
    testDP().then((res) => {
      console.log('-----------', res)
      obtainDeviceData(res.data[0].equipmentCode).then((data) => {
        console.log(data)
      })
    })
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;
   height: 100%;
  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}
.base-content{
  margin-bottom: 12px;
}
.left-base{
  padding: 10px;
  .left-title{
    width: calc(100% - 100px);
  }
}
.topNumItems{
  margin-bottom: 12px;
  width: 100%;
  .col-num:nth-child(2){
    margin:0 30px;
  }
}
.sjgk-content{
   padding: 10px 20px;
   .sjgk-top{
     height: 40px;
     overflow: hidden;
     
     .tip-selects{
       height: 28px;
       line-height: 28px;
       .selects{
         .el-select{
           width: 150px;
         }
       }
     }
   }
   .nav-items{
     width: 100%;
     overflow: hidden;
     .nav-item{
       overflow: hidden;
       background: #FFF;
       padding: 15px 10px;
       border: 1px solid #DFE0E1;
       width: 15%;
       border-radius: 4px;
       .name{
         color: #535557;
         line-height: 20px;
         font-size: 12px;
       }
       .value{
         color: #181D21;
         font-size: 20px;
       }
       .imgIcon{
         width: 30px;
         height: 30px;
         background: #000;
       }
     }
   }
   .echart-content{
     margin-top: 24px;
     .echarts{
       height: 300px;
       background: #000;
     }
   }
   .selectBox{
     width: auto;
     margin-left: 20px;
    
     .box{
       padding: 5px 8px;
       font-size: 12px;
       color: #181D21;
       border: 1px solid #CACCCD;
       border-right: 0;
     }
     .box:nth-child(1){
       border-top-left-radius:4px;
       border-bottom-left-radius:4px;
       margin-left: -1px;
     }
     .box:nth-last-child(1){
       border-right: 1px solid #CACCCD;
        border-top-right-radius:4px;
       border-bottom-right-radius:4px;
     }
     .box.active{
       border: 1px solid #00B23B;
       color: #00B23B;
     }
   }

}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
